package cn.ickck.law_paper_final.mapper;

import cn.ickck.law_paper_final.model.entity.HouseLoan;
import cn.ickck.law_paper_final.model.entity.HouseLoanBatch;
import cn.ickck.law_paper_final.provider.HouseLoanBatchProvider;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;

import java.util.List;

/**
 * @Author: ck
 * @Description:
 * @Date: Create in 12:21 2020/11/7
 */
public interface HouseLoanBatchMapper {
    @Insert("insert into house_loan_batch(`name`,`date`,`key`) values(#{name},#{date},#{key})")
    Integer insert(HouseLoanBatch houseLoanBatch);


    @Select("select count(*) from house_loan_batch")
    int count();

    @Select("select * from house_loan_batch limit #{start},#{end}")
    List<HouseLoanBatch> selectByPage(int start, int end);

    @Delete("delete from house_loan_batch where id = #{id}")
    Integer deleteById(Integer id);


    @UpdateProvider(type = HouseLoanBatchProvider.class,method = "updateHouseLoanBatch")
    Integer update(HouseLoanBatch houseLoanBatch);


    @Select("select `key` from house_loan_batch where id = #{id}")
    HouseLoanBatch selectKeyById(Integer id);

    @Select("select * from house_loan_batch where name like  CONCAT('%',#{key},'%')")
    List<HouseLoanBatch> selectByName(String key);
}
